#include<iostream>
#include<algorithm>
using namespace std;
class Students{
private:
    int ID;
    int talent;
    int virtue;
    int type;
    int sum;
public:
    Students(){
	//doing nothing
    }
    void set_info(int upper,int lower);
    int getID(){
	return ID;
    }
    int gettype(){
	return type;
    }
    int getsum(){
	return sum;
    }
    int getvirtue(){
	return virtue;
    }
    void print(){
	cout<<ID<<" "<<virtue<<" "<<talent<<endl;
    }
};
void Students::set_info(int upper,int lower){
    cin>>ID>>virtue>>talent;
    sum=virtue+talent;
    if(talent>=upper&&virtue>=upper){
	type=1;
    }else if(talent<upper&&virtue>=upper){
	type=2;
    }else if(talent<upper&&virtue<upper&&virtue>=talent){
	type=3;
    }else{
	type=4;
    }
    if(talent<lower||virtue<lower){
	type=5;
    }
}
bool cmp(Students S1,Students S2){
    if(S1.gettype()<S2.gettype()){
	return true;
    }else if(S1.gettype()>S2.gettype()){
	return false;
    }else{
	if(S1.getsum()>S2.getsum()){
	    return true;
	}else if(S1.getsum()<S2.getsum()){
	    return false;
	}else{
	    if(S1.getvirtue()>S2.getvirtue()){
		return true;
	    }else if(S1.getvirtue()<S2.getvirtue()){
		return false;
	    }else{
		if(S1.getID()<S2.getID()){
		    return true;
		}else{
		    return false;
		}
	    }
	}
    }
}
int main(){
    Students Stu[100010];
    int stunum,low,up;
    cin>>stunum>>low>>up;
    for(int i=0;i<stunum;i++){
	Stu[i].set_info(up,low);
    }
    sort(Stu,Stu+stunum,cmp);
    int num=0;
    for(int i=0;i<stunum;i++){
	if(Stu[i].gettype()!=5){
	    num++;
	}
    }
    cout<<num<<endl;
    for(int i=0;i<num;i++){
	if(Stu[i].gettype()!=5){
	    Stu[i].print();
	}
    }
}
